; *** Korean Chess
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com

(version "2.0")
(translate
 ("Red""红方")("Black""黑方")
 ("Soldier" "兵") ("Horse" "马")
 ("Chariot" "车") ("Elephant" "象")
 ("Cannon" "包") ("Mandarin" "士")
 ("General" "将")
)
(define shift          ($1 (verify not-friend?) add) )
(define shift2         ($1 (verify empty?) $2 (verify not-friend?) add) )
(define shift-Elephant ($1 (verify empty?) $2 (verify empty?) $2 (verify not-friend?) add) )
(define slide          ($1 (while empty? add $1) (verify enemy?) add))
(define slide-cannon   ($1 (while empty? $1) (verify (not-piece? Cannon)) $1 (while empty? add $1) (verify enemy?) (verify (not-piece? Cannon)) add))
(define opposed-kings  (n (while empty? n) (verify (piece? General)) add) )
(define shift-fortress ($1 (verify (in-zone? fortress)) (verify not-friend?) add ) )
(define rsetup1
	(Red
         (Soldier a4 c4 e4 g4 i4)
         (Horse b1 h1)
         (Elephant c1 g1)
         (Chariot a1 i1)
         (Mandarin d1 f1)
	 (Cannon b3 h3)
         (General e2)
	)
)
(define rsetup2
	(Red
         (Soldier a4 c4 e4 g4 i4)
         (Horse c1 g1)
         (Elephant b1 h1)
         (Chariot a1 i1)
         (Mandarin d1 f1)
	 (Cannon b3 h3)
         (General e2)
	)
)
(define rsetup3
	(Red
         (Soldier a4 c4 e4 g4 i4)
         (Horse c1 h1)
         (Elephant b1 g1)
         (Chariot a1 i1)
         (Mandarin d1 f1)
	 (Cannon b3 h3)
         (General e2)
	)
)
(define rsetup4
	(Red
         (Soldier a4 c4 e4 g4 i4)
         (Horse b1 g1)
         (Elephant c1 h1)
         (Chariot a1 i1)
         (Mandarin d1 f1)
	 (Cannon b3 h3)
         (General e2)
	)
)
(define bsetup1
	(Black
         (Soldier a7 c7 e7 g7 i7)
         (Horse b10 h10)
         (Elephant c10 g10)
         (Chariot a10 i10)
         (Mandarin d10 f10)
	 (Cannon b8 h8)
         (General e9)
	)
)
(define bsetup2
	(Black
         (Soldier a7 c7 e7 g7 i7)
         (Horse c10 g10)
         (Elephant b10 h10)
         (Chariot a10 i10)
         (Mandarin d10 f10)
	 (Cannon b8 h8)
         (General e9)
	)
)
(define bsetup3
	(Black
         (Soldier a7 c7 e7 g7 i7)
         (Horse c10 h10)
         (Elephant b10 g10)
         (Chariot a10 i10)
         (Mandarin d10 f10)
	 (Cannon b8 h8)
         (General e9)
	)
)
(define bsetup4
	(Black
         (Soldier a7 c7 e7 g7 i7)
         (Horse b10 g10)
         (Elephant c10 h10)
         (Chariot a10 i10)
         (Mandarin d10 f10)
	 (Cannon b8 h8)
         (General e9)
	)
)

(game
   (title "韩国象棋 - 标准布局")
   (description "韩国象棋棋盘类似中国象棋，但是有很大不同。\\具体如下：\\
	1.没有河界，兵在任何时候都可以横走，或沿九宫内斜线移动，仍不可后退。\
	2.象的走法走“用”字，且塞眼点和中国象棋不同。\
	3.车可以沿棋盘的任意直线无限格数移动，包括九宫的斜线。\
	4.将士走法相同，沿九宫的任一条线移动。\
	5.包走法与中国象棋的炮不同。\
	6.开局摆子时，可以将自己一边或两边的马象位置互换。\
	7.韩国象棋允许不走棋跳过。\\
	因为可以互换马象位置，一方的布局有以下4种可能性：\
	内象：两边不互换\
	外象：两边均互换\
	左象：左边互换，右边不换\
	右象：左边不换，右边互换\\
	标准布局是内象对内象。点击“玩法”菜单选择想玩的布局。基于对称性考虑，一些重复布局没有列出。\
	（汉化作者吐槽：原作者你是有多懒才写四种！）")
   (history "The game evolved either from Xiangqi or from a common ancestor.  There has
      not been much written about Korean Chess.  The first Korean Chess association was
      formed in Korea in 1956.  Players are ranked using a Dan system similar to the one
      used for Go.")
   (strategy "Play is similar to Chinese Chess, except that Cannons are weaker (in Xiangqi
      cannons do not leap except when capturing) and Pawns are stronger (they can
      initially move sideways, like promoted pawns in Xiangqi).   Since there is no
      stalemate, the endgame is considerably more drawish than in Xiangqi.   Initially
      the Cannon has no moves, so opening play usually involves getting the Cannons active.
      A rough guide for relative values (courtesy of Pritchard's `Encyclopedia of Chess
      Variants`):\\Chariot = 8\Cannon = 4\Horse = 3\Mandarin = 2\Soldier = 1")
   (players Red Black)
   (music "Audio\\China.mid")
   (win-sound "Audio\\Pan.wav")
   (loss-sound "Audio\\Pan.wav")
   (opening-sound "Audio\\Pan.wav")
   (release-sound "Audio\\BongPercussive.wav")
   (move-sound "Audio\\Bong5th.wav")
   (capture-sound "Audio\\WoodBells.wav")
   (turn-order Red Black)
   (option "pass turn" true)

   (board
      (image "images\Korean_Chess\Shaag\KoreanChess.bmp"
             "images\Korean_Chess\Shaag\KoreanChess.bmp"
             "images\Korean_Chess\KoreanChess.bmp"
             "images\Korean_Chess\KoreanChess.bmp")
      (grid
         (start-rectangle 4 5 46 47)
         (dimensions
             ("a/b/c/d/e/f/g/h/i" (45 0)) ; files
             ("10/9/8/7/6/5/4/3/2/1" (0 45)) ; ranks
         )
         (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			         (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
         )
      )
      (links fortress-ne (d1 e2)(e2 f3) (d8 e9)(e9 f10))
      (links fortress-sw (e2 d1)(f3 e2) (e9 d8)(f10 e9))
	  (links fortress-nw (f1 e2)(e2 d3) (f8 e9)(e9 d10))
	  (links fortress-se (e2 f1)(d3 e2) (e9 f8)(d10 e9))
      (symmetry Black (n s)(s n) (nw sw)(sw nw) (ne se)(se ne)
	            (fortress-ne fortress-se)(fortress-se fortress-ne)
				(fortress-nw fortress-sw)(fortress-sw fortress-nw))
      (zone
         (name fortress)
         (players Red)
         (positions d1 e1 f1 d2 e2 f2 d3 e3 f3)
      )
      (zone
         (name fortress)
         (players Black)
         (positions d10 e10 f10 d9 e9 f9 d8 e8 f8)
      )
   )

   (board-setup
      (rsetup1)
      (bsetup1)
   )

   (piece
      (name Soldier)
      (image Red "images\korean_chess\RSoldier.bmp" "images\korean_chess\Shaag\RSoldier.bmp" Black "images\korean_chess\BSoldier.bmp" "images\korean_chess\Shaag\BSoldier.bmp")
	  (description "兵\\可以向前、左、右移动一步，或沿对方九宫内线斜前移动")
	  (help "兵/卒：向前一步，或横走一步。在对方九宫内还可以沿线斜前一步")
      (moves
         (shift n)
		 (shift e)
		 (shift w)
		 (shift fortress-nw)
		 (shift fortress-ne)
      )
   )
   (piece
      (name Horse)
	   (description "马\\与中国象棋的马完全相同。")
      (help "马：跳日字，蹩腿")
      (image Red "images\korean_chess\RHorse.bmp" "images\korean_chess\Shaag\RHorse.bmp" Black "images\korean_chess\BHorse.bmp" "images\korean_chess\Shaag\BHorse.bmp")
      (moves
	     (shift2 n ne)
	     (shift2 n nw)
	     (shift2 s se)
	     (shift2 s sw)
	     (shift2 e ne)
	     (shift2 e se)
	     (shift2 w nw)
	     (shift2 w sw)
      )
   )
   (piece
      (name Elephant)
	  (description "象\\象走“用”字，\即先横/竖走一步（蹩腿点），然后再同方向飞“田”（田字中间塞眼，同中国象棋象）")
	  (help "象，走用字，蹩腿+塞眼")
      (image Red "images\korean_chess\RElephant.bmp" "images\korean_chess\Shaag\RElephant.bmp" Black "images\korean_chess\BElephant.bmp" "images\korean_chess\Shaag\BElephant.bmp")
      (moves
         (shift-Elephant n ne)
         (shift-Elephant n nw)
         (shift-Elephant s se)
         (shift-Elephant s sw)
		 (shift-Elephant e ne)
         (shift-Elephant e se)
         (shift-Elephant w nw)
         (shift-Elephant w sw)
      )
   )
   (piece
      (name Chariot)
	  (description "车：可以横或纵移动。也可以沿九宫线移动，均不限格数。")
      (help "车：沿线移动，不限格数")
      (image Red "images\korean_chess\RChariot.bmp" "images\korean_chess\Shaag\RChariot.bmp" Black "images\korean_chess\BChariot.bmp" "images\korean_chess\Shaag\BChariot.bmp")
      (moves
         (slide n)
         (slide e)
         (slide s)
         (slide w)
		 (slide fortress-nw)	
		 (slide fortress-ne)	
		 (slide fortress-sw)	
		 (slide fortress-se)	
      )
   )
   (piece
      (name Cannon)
	  (description "包（即韩国象棋的炮）\\
	     \包走法与车相似，即沿线行走。无论吃子还是走子，都必须间隔一个子（炮架）。\并且，包不能吃包，不能以包作为架子。")
      (help "包：隔子走，隔子吃。注意看详细信息。")
      (image Red "images\korean_chess\RCannon.bmp" "images\korean_chess\Shaag\RCannon.bmp" Black "images\korean_chess\BCannon.bmp" "images\korean_chess\Shaag\BCannon.bmp")
      (moves
         (slide-cannon n)
         (slide-cannon e)
         (slide-cannon s)
         (slide-cannon w)
		 (slide-cannon fortress-nw)	
		 (slide-cannon fortress-ne)	
		 (slide-cannon fortress-sw)	
		 (slide-cannon fortress-se)	
      )
   )
   (piece
      (name Mandarin)
      (image Red "images\korean_chess\RMandarin.bmp" "images\korean_chess\Shaag\RMandarin.bmp" Black "images\korean_chess\BMandarin.bmp" "images\korean_chess\Shaag\BMandarin.bmp")
	  (description "士\\士只能在九宫内沿线走一步。")
      (help "士：九宫内沿线走一步")
      (moves
         (shift-fortress n)
         (shift-fortress e)
         (shift-fortress s)
         (shift-fortress w)
		 (shift fortress-nw)	
		 (shift fortress-ne)	
		 (shift fortress-sw)	
		 (shift fortress-se)	
      )
   )
   (piece
      (name General)
      (image Red "images\korean_chess\RGeneral.bmp" "images\korean_chess\Shaag\RGeneral.bmp" Black "images\korean_chess\BGeneral.bmp" "images\korean_chess\Shaag\BGeneral.bmp")
	  (help "将/帅：九宫内沿线一步。不可与对方帅/将照面")
	  (description "帅/将\\
	   帅被将死即算输。帅的走法是九宫内沿线横、直、或斜一步。\双方的将帅不可处于无其他子阻挡的同一条纵线上，称为“照面”。")
      (moves
	     (opposed-kings)
         (shift-fortress n)
         (shift-fortress e)
         (shift-fortress s)
         (shift-fortress w)
		 (shift fortress-nw)	
		 (shift fortress-ne)	
		 (shift fortress-sw)	
		 (shift fortress-se)	
      )
   )
   (loss-condition (Red Black) (checkmated General) )
)

(variant
   (title "韩国象棋 - 内象 vs 外象")
   (board-setup (rsetup1)(bsetup2) )
)
(variant
   (title "韩国象棋 - 内象 vs 左象")
   (board-setup (rsetup1)(bsetup3) )
)
(variant
   (title "韩国象棋 - 内象 vs 右象")
   (board-setup (rsetup1)(bsetup4) )
)

(variant
	(title"-")
)

(variant
   (title "韩国象棋 - 外象 vs 内象")
   (board-setup (rsetup2)(bsetup1) )
)
(variant
   (title "韩国象棋 - 外象 vs 外象")
   (board-setup (rsetup2)(bsetup2) )
)
(variant
   (title "韩国象棋 - 外象 vs 左象")
   (board-setup (rsetup2)(bsetup3) )
)
(variant
   (title "韩国象棋 - 外象 vs 右象")
   (board-setup (rsetup2)(bsetup4) )
)

(variant
	(title"-")
)

(variant
   (title "韩国象棋 - 左象 vs 内象")
   (board-setup (rsetup3)(bsetup1) )
)
(variant
   (title "韩国象棋 - 左象 vs 外象")
   (board-setup (rsetup3)(bsetup2) )
)
(variant
   (title "韩国象棋 - 左象 vs 左象")
   (board-setup (rsetup3)(bsetup3) )
)
(variant
   (title "韩国象棋 - 左象 vs 右象")
   (board-setup (rsetup3)(bsetup4) )
)